clear all
set more off

use  "../data/decile_year_month_data",replace

collapse (sum) chinese100* american100* hispanic100* indian100* russian100* korean100* japanese100* european100*, by(year)
tsset year

*First do by transaction value
gen chiper = chinese100_cash/chinese100_val*100
gen ameper = american100_cash/american100_val*100
gen hisper = russian100_cash/russian100_val*100
gen indper = indian100_cash/indian100_val*100
gen rusper = russian100_cash/russian100_val*100
gen korper = korean100_cash/korean100_val*100
gen japper = japanese100_cash/japanese100_val*100
gen eurper = european100_cash/european100_val*100

label var chiper "Chinese"
label var ameper "American"
label var hisper "Hispanic"
label var indper "Indian"
label var rusper "Russian"
label var korper "Korean"
label var japper "Japanese"
label var eurper "European"

twoway (tsline chiper, lpatter(dash)) (tsline hisper) (tsline indper) (tsline rusper) (tsline korper) (tsline japper) (tsline eurper) (tsline ameper, lpattern(dot)), ///
graphregion(color(white)) bgcolor(white) tlabel(2001(2)2013) ttitle("") ylabel(0(5)35) ytitle("Percent of Transaction Value Made In Cash") legend(rows(3))
graph export "../results/figureA1a.png", replace


*Now do by counts
gen chiper_ct = chinese100cash/chinese100*100
gen ameper_ct = american100cash/american100*100
gen hisper_ct = russian100cash/russian100*100
gen indper_ct = indian100cash/indian100*100
gen rusper_ct = russian100cash/russian100*100
gen korper_ct = korean100cash/korean100*100
gen japper_ct = japanese100cash/japanese100*100
gen eurper_ct = european100cash/european100*100

label var chiper_ct "Chinese"
label var ameper_ct "American"
label var hisper_ct "Hispanic"
label var indper_ct "Indian"
label var rusper_ct "Russian"
label var korper_ct "Korean"
label var japper_ct "Japanese"
label var eurper_ct "European"



twoway (tsline chiper_ct, lpatter(dash)) (tsline hisper_ct) (tsline indper_ct) (tsline rusper_ct) (tsline korper_ct) (tsline japper_ct) (tsline eurper_ct) (tsline ameper_ct, lpattern(dot)), ///
graphregion(color(white)) bgcolor(white) tlabel(2001(2)2013) ttitle("") ylabel(0(5)35) ytitle("Percent of Transaction Counts Made In Cash") legend(rows(3))
graph export "../results/figureA1b.png", replace
